package com.bjsxt.usersCenter.head.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bjsxt.usersCenter.common.controller.BaseController;
import com.bjsxt.usersCenter.common.util.ConstatFinalUtil;
import com.bjsxt.usersCenter.outer.service.IOuterService;

@Controller
@RequestMapping("/outer/")
public class OuterController extends BaseController
{
	@Resource
	private IOuterService outerService;
	
	@ResponseBody
	@RequestMapping(value="/regionList",produces="text/html;charset=UTF-8")
	public String regionList(HttpServletRequest request)
	{
		long st=System.currentTimeMillis();
		
		JSONObject resultJSON=new JSONObject();
		String json=request.getParameter("json");
		if(json==null)
		{
			json="";
		}
		
		JSONObject reqJSON=null;
		
		try
		{
			reqJSON=(JSONObject) JSON.parse(json);
		} catch (Exception e)
		{
			resultJSON.put("code", "11");
			resultJSON.put("info", ConstatFinalUtil.INFO_JSON.get("11"));
		}
		
		try
		{
			if("1".equalsIgnoreCase(reqJSON.getString("version")))
			{
				resultJSON=this.outerService.regionList01Service(reqJSON);
			}else{
				resultJSON.put("version", reqJSON.get("version"));
				
				resultJSON.put("code", "9");
				resultJSON.put("info", ConstatFinalUtil.INFO_JSON.get("9"));
				
				
				
				
			}
		} catch (Exception e)
		{
			resultJSON.put("code", "-1");
			resultJSON.put("info", ConstatFinalUtil.INFO_JSON.get("-1")+e.toString());
		}
		
		
		long ed=System.currentTimeMillis();
		resultJSON.put("consume", (ed-st)+"毫秒");
		
		return resultJSON+"";
	}
	
	
	
}
